package JdbcTemplate;

import MethodDemo.User;
import org.junit.Test;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

public class JdbcTemplateDemo1 {
    @Test
    public void test(){
        //创建jdbctemplate对象
        JdbcTemplate jdbcTemplate = new JdbcTemplate(JdbcUtils.getDataSource());
    //编写sql语句
        String sql="select * from user where id=?";
        User user = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(User.class), 1);
        System.out.println(user);
    }
    @Test
    public void test2(){
        //创建jdbctemplate对象
        JdbcTemplate jdbcTemplate = new JdbcTemplate(JdbcUtils.getDataSource());
    //编写sql语句
        String sql="select * from user";
        //执行方法
        
    }
}
